<template>
  <div id="BuildingApplication">
    <div class="SQList" ref="SQList" v-if="$store.state.isGJ">
      <van-tabs class="subTab" color="#007DFB" line-width="60px" line-height="4px" title-active-color="#007DFB" v-model="active" @click="handleclickto" swipeable>
        <van-tab title="我的待办">
          <!-- 添加一个搜索 -->
          <van-search background="#eee" v-model="value1" placeholder="请输入搜索关键词" @search="serachData" />
          <ul class="listWrap">
            <!-- <div style="border-top: 1px solid #d2d2d2; margin-top: 4px; clear: both"></div> -->
            <div style="position: relative">
              <li v-show="contentData.length > 0" v-for="(item, index) in contentData" :key="index">
                <div style="float: left; width: 10%; height: 100%; position: relative; top: 38px" v-if="isnhzgChe">
                  <van-radio-group v-model="index1">
                    <van-radio :name="index"></van-radio>
                  </van-radio-group>
                </div>
                <div :style="{ float: 'left', width: isnhzgChe ? '90%' : '100%' }" @click="getListData(item)">
                  <p class="p1" style="font-weight: bold">
                    <span style="float: left">{{ item.personname }}</span>
                    <span style="float: right">{{ item.applytime || '暂无数据' }}</span>
                  </p>
                  <p class="p3">
                    <span style="float: left">流水号：{{ item.serialNumber }}</span>
                    <span style="float: right">{{ item.APPLYTIME }}</span>
                  </p>
                  <p class="p3">
                    <span style="float: left; overflow: hidden; text-overflow: ellipsis">地址：{{ item.address || '暂无数据' }}</span>
                    <span style="float: right" :style="{ color: item.isDelete == 0 ? 'green' : 'red' }">进度: {{ item.currentLink || '暂无数据' }}</span>
                  </p>
                </div>
              </li>
            </div>
            <div style="height: 60vh; text-align: center; padding-top: 20vh" v-show="noData">
              <div style="margin-bottom: 10px">
                <img src="https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/DSF/50.png" />
              </div>
              <div>暂无数据</div>
            </div>
          </ul>
        </van-tab>
        <van-tab title="退件记录">
          <tuijianList></tuijianList>
        </van-tab>
      </van-tabs>
    </div>
    <div class="SQList" ref="SQList" v-else>
      <van-tabs v-model="active" color="#007DFB" line-width="60px" line-height="4px" title-active-color="#007DFB" @click="handleclickto" swipeable>
        <van-tab title="我的待办">
          <ul class="listWrap">
            <!-- <div style="border-top: 1px solid #d2d2d2; margin-top: 4px; clear: both"></div> -->
            <div style="clear: both">
              <li v-show="contentData.length > 0" v-for="(item, index) in contentData" @click="contentDataClick(item)" :key="index">
                <p class="p1">
                  <span style="float: left">{{ item.NODE_NAME }}</span>
                  <span style="float: right">{{ item.HOUSEAPPLICANT }}</span>
                </p>
                <p class="p3">
                  <span style="float: left">进度：{{ item.PROC_NAME }}</span>
                  <span style="float: right">{{ item.APPLYTIME }}</span>
                </p>
                <p class="p3">
                  <span style="float: left">地址：{{ item.PERMANENTADDR ? item.PERMANENTADDR : '暂无数据' }}</span>
                </p>
              </li>
            </div>
            <div style="height: 60vh; text-align: center; padding-top: 20vh" v-show="noData">
              <div style="margin-bottom: 10px">
                <img src="https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/DSF/50.png" />
              </div>
              <div>暂无数据</div>
            </div>
          </ul>
        </van-tab>
        <van-tab title="申请记录">
          <myshenQing></myshenQing>
        </van-tab>
      </van-tabs>
    </div>
    <div class="bottom">
      <div style="height: 60px; text-align: center; padding-top: 10px">
        <van-button style="width: 90vw" type="info" @click="handleGotoC" v-show="!noData">{{ isnhzgChe ? '发起撤销申请' : '撤销申请' }} </van-button>
      </div>
    </div>
    <van-popup v-model="shoulm1">
      <div class="con_box">
        <h3>{{ text1.title }}</h3>
        <p>{{ text1.message }}</p>
        <div class="btnv">
          <span @click="handleClose1()" v-if="text1.btn.cancelText">
            {{ text1.btn.cancelText }}
          </span>
          <span @click="handleOk1(SaveData)" v-if="text1.btn.okText">
            {{ text1.btn.okText }}
          </span>
        </div>
      </div>
    </van-popup>
    <van-popup v-model="shoulm1">
      <div class="con_box">
        <h3>{{ text.title }}</h3>
        <p>{{ text.message }}</p>
        <div class="btnv">
          <span @click="handleClose1()" v-if="text.btn.cancelText">
            {{ text.btn.cancelText }}
          </span>
          <span @click="handleOk1()" v-if="text.btn.okText">
            {{ text.btn.okText }}
          </span>
        </div>
      </div>
    </van-popup>
    <!-- <van-action-sheet style="padding: 20px" class="content1" cancel-text="确定" @cancel="handleche" v-model="shoulm2" title="撤销意见">
      <div class="content">
        <div style="display: flex; justify-content: center; align-items: center; border-bottom: 1px solid #d2d2d2; color: black">
          <span style="color: #ff0000">*</span>
          <van-field clickable name="picker" v-model="DHLY" label="撤销意见" placeholder="请填写撤销意见" />
        </div>
        <div style="text-align: center">
          <van-button type="info" style="width: 90vw" @click="handleche">确定</van-button>
        </div>
      </div>
    </van-action-sheet> -->
    <van-popup v-model="shoulm2" style="padding: 20px">
      <div class="content">
        <div style="display: flex; justify-content: center; align-items: center; border-bottom: 1px solid #d2d2d2; color: black">
          <span style="color: #ff0000">*</span>
          <van-field clickable name="picker" v-model="DHLY" label="撤销意见" placeholder="请填写撤销意见" />
        </div>
        <div style="padding-top: 20px;">
          <van-button type="info" style="width: 90vw" @click="handleche">确定</van-button>
        </div>
      </div>
    </van-popup>
  </div>
</template>

<script>
import { ExecProcedure, JFDataList, FileServerProxy, DataDelete } from '../../utils/api'
import { GJDBFunction, GJDBFunction2 } from '../../utils/queryData'
import timeFormat from '@/utils/timeFormat.js'
import myshenQing from './myshenQing'
import tuijianList from './tuijianList.vue'
import { isLinAn } from '@/utils/isLinAn'
import { GSA_Add, GSA_Search } from '@/common/commonApi'
import { v4 as uuidv4 } from 'uuid'
export default {
  name: 'BuildingApplication',
  data() {
    return {
      noData: false,
      DHLY: '',
      ISGJ: false,
      shoulm2: false,
      index1: true,
      isnhzgChe: false,
      handleGoto: 0,
      nowIndex: 1,
      newItem: [],
      value1: '',
      tableData: {},
      active: 'first',
      contentData: [],
      text1: {
        title: '提示',
        message: '请确认是否需要更换工匠?',
        btn: {
          okText: '确定',
          cancelText: '取消'
        }
      },
      shoulm1: false,
      contentData1: [
        {
          name: '我要建房申请',
          num: 0
        },
        {
          name: '我的贷款申请',
          num: 0
        },
        {
          name: '我购买的保险',
          num: 0
        },
        {
          name: '我要改扩建申请',
          num: 0
        },
        {
          name: '我要危改申请',
          num: 0
        },
        {
          name: '我要流转申请',
          num: 0
        },
        {
          name: '我要办理不动产权证申请',
          num: 0
        }
      ],
      shoulm1: false,
      chehui: [],
      text: {
        title: '提示',
        message: '是否更换工匠?',
        btn: {
          okText: '确定',
          cancelText: '取消'
        }
      },
      shenkaobeiData: [],
      bottomData: [
        {
          name: '首页',
          icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/ZLJ/20.png',
          icons: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/ZLJ/20-1.png'
        },
        {
          name: '我的待办',
          icons: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/ZLJ/21.png',
          icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/ZLJ/21-1.png'
        },
        {
          name: '我的收藏',
          icons: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/ZLJ/22.png',
          icon: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/ZLJ/22-1.png'
        }
      ]
    }
  },
  components: {
    myshenQing,
    tuijianList
  },
  methods: {
    handleClose1() {
      this.shoulm1 = false
    },
    serachData(val) {
      if (!val) return (this.contentData = this.shenkaobeiData)
      this.contentData = this.shenkaobeiData.filter((item) => {
        return item.personname && item.personname.indexOf(val) > -1
      })
    },
    handleOk1() {
      //直接发送
      //this.shoulm1 = true;
      this.$router.push({
        path: '/TreeSelect',
        query: { data: this.newItem, isnhzg: 1 }
      })
    },
    bottomClick(index) {
      switch (index) {
        case 0:
          this.$router.push({
            path: '/ZLJIndex'
          })
          break
        case 1:
          this.$router.push({
            path: 'MyAgent'
          })
          break
        case 2:
          this.$router.push({
            path: 'MyEnshrine'
          })
          break
      }
    },
    handleclickto(data) {
      console.log(data)
      if (data == '1') {
        this.$store.commit('getContent', [])
      }
    },
    async handleche(data) {
      //新版流程
      if (!this.DHLY) {
        this.$toast.fail('请填写撤销意见')
        return false
      }
      var timeFormat1 = timeFormat(null, 'yyyy-mm-dd hh:MM:ss')
      //新版新增不同的操作逻辑
      if (this.chehui.versionNumber == 1) {
        let name = window.localStorage.getItem('DanDianName')
        //获取当前的时间
        let uuid = uuidv4()
        let parmes = [{ ROW_GUID: uuid, TO_ROW_GUID: this.chehui.rowGuid, SQLY: this.DHLY, SQR: name, SQSJ: timeFormat1, DQZT: this.chehui.isDelete }]
        //保存数据
        const res = await GSA_Add('80a12eb5-d632-4422-a523-aed6d1ba5d94', true, ...parmes)
        //更改状态
        //先根据当前行的row_guid来获取业务系统当前行的数据
        let isNHApplyParamNH = {
          procName: this.chehui.versionNumber == 1 ? 'ZJBXDBXV2' : 'ZJBXDBX',
          dtParams: JSON.stringify([{ I_USERID: "'" + this.chehui.rowGuid + "'", I_SJH: "'" + this.chehui.serialNumber + "'" }]),
          token: window.localStorage.getItem('token')
        }
        let xcfycjtfnApplynh = {
          accessCode: '69db6bece3a7480592e2ec753d1e335e',
          cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
          params: isNHApplyParamNH
        }
        const resxcfycjtApplynh = await FileServerProxy(xcfycjtfnApplynh)
        let data = JSON.parse(resxcfycjtApplynh.data.data).Data[0]
        if (JSON.parse(resxcfycjtApplynh.data.data).Data.length > 0) {
          let parmes1 = [{ PKID: data.PKID, ISDELETE: 12 }]
          const upres = await GSA_Add('06424a16-746c-4650-ae97-a774402de7cd', false, ...parmes1)
        }
      } else {
        //旧版流程
        console.log(this.chehui)
        let date = timeFormat(null, 'yyyy-mm-dd hh:MM:ss')
        let uuid1 = uuidv4()
        let data1 = {
          ROW_GUID: uuid1,
          TODATA_GUID: this.chehui.rowGuid,
          SIGNERID: window.localStorage.getItem('userId'),
          SIGNDATE: date,
          SORTNUM: 119,
          SIGNERNAME: window.localStorage.getItem('DanDianName'),
          OPINION: this.DHLY
        }
        let querys = [
          {
            field: 'TODATA_GUID',
            value: this.chehui.rowGuid
          }
        ]
        const result = await GSA_Search('ea6c9e0c-bf2c-4fe0-9c33-fb19d4b6a693', querys)
        let p = {
          rowGuid: this.chehui.rowGuid,
          serialNumber: this.chehui.serialNumber
        }
        const resData = await DataDelete(p)
        if (result.Data.length > 0) {
          this.$toast.fail('该件已经撤销了')
          return false
        }
        const res = await GSA_Add('ea6c9e0c-bf2c-4fe0-9c33-fb19d4b6a693', true, data1)
      }
      this.getcontentData()
      this.shoulm2 = false
    },
    async getListData(item) {
      //改变当前citycode
      //根据versionNumber 来判断是新流程还是旧流程
      debugger
      if (item.s) {
        // window.localStorage.setItem('citycode', item.s)
        if (item.cun !== null) {
          const res = await isLinAn(item.cun)
          if (res) {
            window.localStorage.setItem('citycode', '330112000000')
          } else {
            let code1 = item.cun.slice(0, 4) + '00000000'
            window.localStorage.setItem('citycode', code1)
          }
        } else {
          window.localStorage.setItem('citycode', '441300000000')
        }
      }
      this.$store.commit('getVERSIONNUMBER', item.versionNumber)
      let isNHApplyParamNH = {
        procName: item.versionNumber == 1 ? 'ZJBXDBXV2' : 'ZJBXDBX',
        dtParams: JSON.stringify([{ I_USERID: "'" + item.rowGuid + "'", I_SJH: "'" + item.serialNumber + "'" }]),
        token: window.localStorage.getItem('token')
      }
      let xcfycjtfnApplynh = {
        accessCode: '69db6bece3a7480592e2ec753d1e335e',
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: isNHApplyParamNH
      }
      const resxcfycjtApplynh = await FileServerProxy(xcfycjtfnApplynh)
      try {
        if (JSON.parse(resxcfycjtApplynh.data.data)?.Data.length == 0) {
          this.$toast.fail('当前案卷村委未受理')
          return false
        }
      } catch (e) {
        this.$toast.fail('服务异常,异常编号为' + JSON.parse(resxcfycjtApplynh.data.data)['异常编号'])
        return false
      }
      let data = JSON.parse(resxcfycjtApplynh.data.data).Data[0]
      if (data.wf_guid == '{7A440F29-3FD5-498A-AE43-F6C4E1350B34}') {
        isNHApplyParamNH.procName = 'ZJBXDBX_SDC'
        const resxcfycjtApplynh1 = await FileServerProxy(xcfycjtfnApplynh)
        data = JSON.parse(resxcfycjtApplynh1.data.data).Data[0]
      }
      debugger
      console.log(data, 'xiaohe')
      if (data) {
        this.contentDataClick(data, item.versionNumber)
      } else {
        //跳转
        debugger
        console.log(item)
        if (item?.PROC_GUID || item.OLD_GJ == 1) {
          this.getDataJD(item)
        } else if (data?.PROC_GUID || item.OLD_GJ == 1) {
          this.getDataJD(data)
        } else {
          this.$toast.fail('当前案卷村委暂未受理')
        }
      }
    },
    //获取阶段数据
    async getDataJD(item) {
      // var data1 = item.rowGuid==undefined?item.ROW_GUID_2:item.rowGuid
      // var data2 = item.serialNumber==undefined?item.LSH:item.serialNumber
      // console.log(data1,data2)
      // let isNHApplyParamNH = {
      //   procName: 'ZJBXBLGCJYJ',
      //   dtParams: JSON.stringify([{ I_USERID: "'" + data1 + "'", I_LSH: "'" + data2 + "'"}]),
      //   token: window.localStorage.getItem('token'),
      // }
      // let xcfycjtfnApplynh = {
      //   accessCode: '69db6bece3a7480592e2ec753d1e335e',
      //   cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
      //   params: isNHApplyParamNH,
      // }
      // const resxcfycjtApplynh = await FileServerProxy(xcfycjtfnApplynh)
      // try{
      //   var data = JSON.parse(resxcfycjtApplynh.data.data).Data[0]
      // }catch(err){
      //   this.$toast.fail('暂无详情数据')
      // }
      // if(data){
      this.$router.push({
        path: '/KeyLine',
        query: { PROC_GUID: item.PROC_GUID }
      })
      // } else{
      //   this.$toast.fail('暂无详情数据')
      // }
    },
    async contentDataClick(item, versionNumber) {
      debugger
      console.log(item, 'hahahahah')
      window.localStorage.setItem('UUID1', '')
      window.sessionStorage.setItem('PKID', item.PKID)
      window.sessionStorage.setItem('ROW_GUID1', JSON.stringify(item))
      let isgj = window.localStorage.getItem('isGJM')
      if (versionNumber == 1 || item.VERSIONNUMBER == 1) {
        this.$store.commit('getVERSIONNUMBER', versionNumber ? versionNumber : item.VERSIONNUMBER)
        console.log(this.$store.state.VERSIONNUMBER, 'VERSIONNUMBERVERSIONNUMBERVERSIONNUMBER')
        //新流程
        if (item.NODE_GUID == '{1055401E-8D9C-4AA8-AE67-394146C627FA}') {
          this.$router.push({
            path: '/drawingCraftsman',
            query: { data: JSON.stringify(item) }
          })
        } else if (!isgj && item.NODE_GUID == '{FEF0E7B0-F048-42E0-998E-06387B0D03DB}') {
          this.$router.push({
            path: '/ConstructionContract',
            query: { data: JSON.stringify(item) }
          })
        } else {
          this.$router.push({
            path: '/applyFor',
            query: { data: JSON.stringify(item) }
          })
        }
        // else if(item.NODE_NAME == '选施工单位、签订合同'){

        // }
      } else {
        //需要判断当前是不是工匠 工匠页面需要展示多条
        if (item.NODE_NAME === '农户选图集、选工匠') {
          //农户选图集、选工匠 签合同环节
          this.handleGoto = 0
        } else if (
          (item.NODE_GUID === '{FAFEF7FF-6294-489A-A5DF-53906712EBEE}' || item.NODE_GUID === '{FEF0E7B0-F048-42E0-998E-06387B0D03DB}') &&
          (item.OPTYPE == 59 ? item.HTQDZT == null || item.HTBHQDZT == null : item.HTBHQDZT == null || item.F_JZQYSGFZR == null || item.F_JZQYXMFZR == null)
        ) {
          //获取数据 工匠签合同环节

          this.handleGoto = 1
        } else if (
          (item.NODE_GUID === '{FAFEF7FF-6294-489A-A5DF-53906712EBEE}' || item.NODE_GUID === '{FEF0E7B0-F048-42E0-998E-06387B0D03DB} ' || item.WF_GUID == '{9FF1C524-B55F-4A45-83B3-6EA46CF32092}') &&
          (item.OPTYPE != '60' ? item.HTQDZT != null && item.HTBHQDZT != null : item.HTBHQDZT != null && item.F_JZQYSGFZR != null && item.F_JZQYXMFZR != null)
        ) {
          if (!this.$store.state.isGJ) {
            debugger
            this.$toast.fail('请前往我的项目办理')
            this.handleGoto = -1
          } else {
            debugger
            this.handleGoto = 4
          }
        } else if (item.NODE_NAME === '基槽验线') {
          if (!this.$store.state.isGJ) {
            this.$toast.fail('请前往我的项目办理')
            this.handleGoto = -1
          } else {
            this.handleGoto = 6
          }
        } else if (item.NODE_NAME == '一层立模') {
          if (!this.$store.state.isGJ) {
            this.$toast.fail('请前往我的项目办理')
            this.handleGoto = -1
          } else {
            this.handleGoto = 8
          }
        } else if (item.NODE_NAME === '竣工验收') {
          //获取数据
          if (!this.$store.state.isGJ) {
            this.$toast.fail('请前往我的项目办理')
            this.handleGoto = -1
          } else {
            this.handleGoto = 7
          }
        } else if (
          item.NODE_GUID == '{D2048C7B-88F9-453C-8FB9-6CFBE287634F}' ||
          item.NODE_GUID == '{0A7F08C3-5939-4254-A437-9468ABF192D5}' ||
          item.NODE_GUID == '{757359B4-6AC2-4860-899F-94A348EC0177}' ||
          item.NODE_GUID == '{B6C36D7F-E42E-49EC-B7EA-9CCF2449DB2A}' ||
          item.NODE_GUID == '{0C629D9A-8AFB-4012-A4CC-4D870229DC38}' ||
          item.NODE_GUID == '{B3ACD6E6-CD10-42B4-9C36-B981DA0129E4}' ||
          item.NODE_GUID == '{FB74960E-0585-4B35-842F-D5DDEF3E00F3}'
        ) {
          //现场放养农户整改
          debugger
          //
          this.handleGoto = 20
        } else if (item.NODE_GUID == '{CAA6567C-2642-4F1C-BC61-2C407C10159B}') {
          this.handleGoto = 21
        } else if (
          item.NODE_GUID == '{FB74960E-0585-4B35-842F-D5DDEF3E00F3}' ||
          item.NODE_GUID == '{B7A28CFC-E12B-4A1C-B3E3-E5D9EA7BEACE}' ||
          item.NODE_GUID == '{FDECC30A-1F95-4375-B025-795780894411}'
        ) {
          window.sessionStorage.setItem('fileData', JSON.stringify(item))
          this.handleGoto = -1
          // 变更：NODE_GUID为 "{0D787A05-D0F0-4585-B69B-CBB05E65E684}" 时 为农户整改
          // 申请：NODE_GUID为 "{B7A28CFC-E12B-4A1C-B3E3-E5D9EA7BEACE}" 时 为农户整改
          // 延期：NODE_GUID为 "{FDECC30A-1F95-4375-B025-795780894411}" 时 为农户整改
          if (item.NODE_GUID == '{B7A28CFC-E12B-4A1C-B3E3-E5D9EA7BEACE}') {
            this.$route.push({
              path: '/fileData',
              query: {
                data: JSON.stringify(item)
              }
            })
          } else if (item.NODE_GUID == '{0D787A05-D0F0-4585-B69B-CBB05E65E684}') {
            window.sessionStorage.setItem('RUNTYPE', 2)
            this.$router.push({
              path: '/biangeng'
            })
          } else {
            window.sessionStorage.setItem('RUNTYPE', 5)
            this.$router.push({
              path: '/biangeng'
            })
          }
        } else if (
          item.wf_guid == '{612C9C60-8D18-4D23-BF32-E9D9D01BB0EA}' ||
          item.wf_guid == '{460B4B5F-C3C2-4D4D-A702-17D4B4A3252F}' ||
          item.wf_guid == '{7F042B34-7091-4884-A5D6-A615AE55497D}' ||
          item.wf_guid == '{8FAD71FB-7756-4F0A-BEE8-4F6397B075A8}'
        ) {
          if (
            item.NODE_GUID == '{0A7F08C3-5939-4254-A437-9468ABF192D5}' ||
            item.NODE_GUID == '{FB74960E-0585-4B35-842F-D5DDEF3E00F3}' ||
            item.NODE_GUID == '{0C629D9A-8AFB-4012-A4CC-4D870229DC38}' ||
            item.NODE_GUID == '{B53DD38D-3717-499F-8FAD-BDC6C1E35C0E}'
          ) {
            //调用存储过程
            this.handleGoto = 20
          }
        } else if (item.NODE_GUID == '{1735EC07-C119-430C-BEBD-B26818E9B006}' || item.NODE_GUID == '{FDECC30A-1F95-4375-B025-795780894411}') {
          // 农户整改节点
          debugger
          this.handleGoto = 25
        } else if (item.NODE_GUID == '{E349B5CD-E963-4A17-ABE4-258EF79C55F2}' && item.WF_GUID == '{5F605C24-CFE0-49A1-B4EC-2BA85C5FF672}') {
          //代表施工备案环节
          this.handleGoto = 26
        } else {
          this.getDataJD(item)
          // this.$notify({ type: "warning", message: "当前环节不需要处理!" });
          this.handleGoto = -1
        }
        // } else {

        // }
        this.$store.commit('gettoGuid', item)
        this.$store.commit('getHJZT', this.handleGoto)
        //跳转到选择工匠页面 //
        if (this.handleGoto == 0) {
          if (item.BUILDTYPE == 14) {
            window.localStorage.setItem('SSZZ_CITYNAME', item.VILLAGE)
          } else {
            window.localStorage.setItem('TOWN_CITYNAME', item.CUN)
          }
          window.localStorage.setItem('GJRowGUID', item.ROW_GUID)
          window.localStorage.setItem('XTXGJGJID', item.GJID)
          this.$router.push({
            path: '/ChooseCraftsman'
          })
          this.$store.commit('getXTXGJData', item)
        } else if (this.handleGoto == 1) {
          //签订合同页面
          debugger
          console.log(item.HTQDZT, item.HTBHQDZT, '哈哈哈哈哈哈哈')
          if (item.OPTYPE != '60' ? item.HTQDZT == null || item.HTBHQDZT == null : item.HTBHQDZT == null || item.F_JZQYSGFZR == null || item.F_JZQYXMFZR == null) {
            window.localStorage.setItem('UUID1', '')
            debugger
            console.log(item, 'jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj')
            this.tableData = item
            //农户点击签合同件需要提示是否更换工匠
            if (this.$store.state.isGJ && item.OPTYPE != '60') {
              this.shoulm1 = true
            } else {
              this.$router.push({
                path: '/ConstructionContract',
                query: { data: JSON.stringify(item) }
              })
            }
          } else {
            this.$router.push({
              path: '/CompletionAcceptance',
              query: { data: JSON.stringify(item) }
            })
          }
        } else if (this.handleGoto == 20) {
          //调用存储过程
          const res = await GJDBFunction2('IN_SDCZJ_TASK', [{ beTASKID: item.TASK_ID, beWF_GUID: item.WF_GUID }])
          if (res?.data == null) {
            this.$toast.success('发送成功')
          } else {
            this.$toast.fail('发送失败')
          }
        } else if (
          this.handleGoto != -1 &&
          this.handleGoto != 10 &&
          this.handleGoto != 11 &&
          this.handleGoto != 12 &&
          this.handleGoto != 13 &&
          this.handleGoto != 21 &&
          this.handleGoto != 25 &&
          this.handleGoto != 26
        ) {
          this.$router.push({
            path: '/CompletionAcceptance',
            query: { data: JSON.stringify(item) }
          })
        } else if (this.handleGoto == 21) {
          this.$router.push({
            path: '/fileData'
          })
          window.sessionStorage.setItem('fileData', JSON.stringify(item))
          window.sessionStorage.setItem('ISBian', false)
        } else if (this.handleGoto == 25) {
          this.$router.push({
            path: '/fileData'
          })
          window.sessionStorage.setItem('fileData', JSON.stringify(item))
          window.sessionStorage.setItem('ISBian', true)
        } else if (this.handleGoto == 26) {
          //掉接口查询施工备案流程是否结束  结束发起四到场，否则 走原来逻辑
          this.$router.push({
            path: '/CompletionAcceptance',
            query: { data: JSON.stringify(item) }
          })
        }
      }
    },
    handleGotoC() {
      if (this.isnhzgChe) {
        this.$confirm({
          title: '提示',
          message: '发起撤销申请后，系统将不在继续进行建房审批业务办理',
          btn: {
            okText: '确定',
            cancelText: '取消'
          }
        })
          .then(() => {
            // do somethingthis.isnhzgChe = true
            this.isnhzgChe = false
            //
            this.chehui = this.contentData[this.index1]
            if (this.contentData[this.index1].isDelete == 1) {
              this.$toast.fail('已注销,请勿重复操作!')
              return false
            }
            // 需要弹出弹窗填写退回意见
            this.shoulm2 = true
          })
          .catch(() => {
            console.log('no')
          })
      }
      this.isnhzgChe = true
    },
    handleOk1(data) {
      // this.handleButton();
      //更换工匠 标识
      window.sessionStorage.setItem('ChangeGJ', true)
      //跳入更换工匠页面
      this.$router.push({
        path: 'craftsmanServices',
        query: {
          id1: '更换工匠',
          dataValue: JSON.stringify(this.tableData)
        }
      })
    },
    handleClose1() {
      this.shoulm1 = false
      this.$router.push({
        path: '/ConstructionContract',
        query: { data: JSON.stringify(this.tableData) }
      })
    },
    getcontentData: async function (data) {
      //   if (!window.localStorage.getItem('token') || window.localStorage.getItem('token') == null || window.localStorage.getItem('token') == 'null') {
      //     this.contentData = []
      //     this.contentData1[0].num = 0
      //     this.noData = true
      //     return
      //   }
      this.contentData = []
      this.contentData1[0].num = 0
      if (!this.$store.state.isGJ) {
        // let params = {
        //   dataguid: '9d97398e-6e18-45f1-932b-bd59cb54a0be',
        //   searchObject: [],
        //   token: window.localStorage.getItem('token'),
        // }
        // let params1 = {
        //   accessCode: '688bd3883572440a859dfd8ba9194e7b',
        //   cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        //   params: params,
        // }
        var res = await GJDBFunction('CRAFTSMAN', '1', window.localStorage.getItem('citycodeChange'))
        var res1 = await GJDBFunction('CRAFTSMANV2', '1', window.localStorage.getItem('citycodeChange'))
        this.contentData1[0].num = res.length + res1.length
        this.contentData = res.concat(res1)
        this.contentData.forEach((item) => {
          item.index1 = false
        })
        // if (res.length == 0) {
        //   let params1 = {
        //     // "dataguid": "5a898987-5c64-4857-92c8-469d05c92c0c",
        //     dataguid: '9d97398e-6e18-45f1-932b-bd59cb54a0be',
        //     searchObject: [],
        //     bizGuid: 'd718f2a6-6d0a-42d2-9f03-e396fd056b79',
        //     token: window.localStorage.getItem('token'),
        //   }
        //   let params2 = {
        //     accessCode: '688bd3883572440a859dfd8ba9194e7b',
        //     cityCode: window.localStorage.getItem('citycode')
        //       ? window.localStorage.getItem('citycode')
        //       : '441300000000',
        //     params: params1,
        //   }
        //   var res1 = await QuerySignCallback(params2)
        //   var parmes = eval('(' + res1.data.data + ')').Data
        //   this.contentData1[0].num = parmes.length
        //   this.contentData = parmes
        // } else {
        // this.contentData1[0].num = res.length
        // this.contentData = res
        // }
        console.log(res)
        this.contentData.length == 0 ? (this.noData = true) : (this.noData = false)
      }
      //农户逻辑
      else if (this.$store.state.isGJ) {
        try {
          // let params = {
          //   dataguid: '5a898987-5c64-4857-92c8-469d05c92c0c',
          //   searchObject: [],
          //   bizGuid: 'd718f2a6-6d0a-42d2-9f03-e396fd056b79',
          //   token: window.localStorage.getItem('token'),
          // }
          // let params2 = {
          //   accessCode: '688bd3883572440a859dfd8ba9194e7b',
          //   cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
          //   params: params,
          // }
          // var parmes = {}
          // var res = await QuerySignCallback(params2)
          // parmes = eval('(' + res.data.data + ')').Data
          // let params1 = {
          //   // "dataguid": "5a898987-5c64-4857-92c8-469d05c92c0c",
          //   dataguid: '8478109f-1194-4126-ab97-b2f927368e7b',
          //   searchObject: [],
          //   bizGuid: 'd718f2a6-6d0a-42d2-9f03-e396fd056b79',
          //   token: window.localStorage.getItem('token'),
          // }
          // let params3 = {
          //   accessCode: '688bd3883572440a859dfd8ba9194e7b',
          //   cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
          //   params: params1,
          // }
          // var res1 = await QuerySignCallback(params3)
          // let paer = eval('(' + res1.data.data + ')').Data

          const res2 = await JFDataList(window.localStorage.getItem('DanDianid'))
          // res2.data.data.pageList.forEach(item=>{
          //   if(item.personname.indexOf('乐金')>-1){
          //     this.contentData.push(item)
          //   }
          // })
          this.contentData = res2.data.data.pageList
          //深拷贝一层
          this.shenkaobeiData = JSON.parse(JSON.stringify(this.contentData))
          this.contentData1[0].num = res2.data.data.totalCount
        } catch (err) {
          this.contentData = []
        }
      }
      this.contentData.length == 0 ? (this.noData = true) : (this.noData = false)
      this.$nextTick(() => {
        // this.scroll = new BScroll(this.$refs.SQList, {
        //   click: true
        // })
      })
    }
  },
  mounted() {
    if (!this.$store.state.isGJ) {
      this.ISGJ = true
    }
    window.sessionStorage.removeItem('fileData')
    window.sessionStorage.removeItem('GJdata')
    window.sessionStorage.removeItem('JZGSData')
    this.getcontentData()
    if (ZWJSBridge) {
      ZWJSBridge.setTitle({
        title: '我的待办'
      })
        .then((res) => {})
        .catch((err) => {})
    }
  }
}
</script>

<style scoped lang="scss">
#BuildingApplication {
  height: 100%;
  position: relative;

  .SQList {
    width: 100vw;
    height: calc(100% - 50px);
    overflow-y: auto;
  }

  .bottom {
    clear: both;
    position: absolute;
    bottom: 0;
    width: 100%;
    text-align: center;
  }

  .van-popup {
    border-radius: 10px;

    .con_box {
      width: 270px;
      line-height: 1;
      text-align: center;
      color: #4d5c82;
      padding: 15px;
      box-sizing: border-box;

      > h3 {
        font-size: 20px;
        margin-top: 10px;
        margin-bottom: 20px;
      }

      > p {
        font-size: 17px;
        margin-bottom: 30px;
      }

      .btnv {
        display: flex;
        justify-content: space-between;

        > span {
          display: block;
          width: 114px;
          background-color: #e0e5f5;
          text-align: center;
          line-height: 44px;
          font-size: 17px;
        }

        > span:last-of-type {
          background-color: #1288fe;
          color: #ffffff;
        }
      }
    }
  }
}
</style>
